# 带自编译的Dockerfile
# alpine的源配置的是ustc.可以更换的.

# complie
FROM golang:1.19-alpine AS golang
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories \
        && apk add git \
        && go env -w GOPROXY=https://goproxy.cn \
        && git clone https://gitee.com/cynen/alertmanager-wechatrobot-webhook.git \
        && cd alertmanager-wechatrobot-webhook \
        && CGO_ENABLE=0 go build -o wechat-webhook


# build images

FROM alpine:3.17
ENV LANG C.UTF-8
ENV TZ=Asia/Shanghai
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories \
    && apk update && apk upgrade \
    && apk add ca-certificates\
    && update-ca-certificates \
    && apk --no-cache add openssl wget \
    && apk add --no-cache bash tzdata curl \
    && set -ex

COPY --from=golang /go/alertmanager-wechatrobot-webhook/wechat-webhook /usr/bin/

CMD ["wechat-webhook"]